﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace homework1
{
    class Program
    {
        static void Main(string[] args)
        {
            f();
        }
        //用户输入正方形边长，用* 打印出实心正方形。
        //如：用户输入5，则输出如下图形。
        //*****
        //*****
        //*****
        //*****
        //*****
        public static void a() {
            Console.WriteLine("请输入正方形的边长：");
            int ab = int.Parse(Console.ReadLine());
            int[,] arr = new int[ab,ab];
            for (int i = 0; i < ab; i++)
            {
                for (int j = 0; j < ab; j++)
                {
                    Console.Write("* ");
                }
                Console.WriteLine();
            }
            Console.ReadKey();
        }
        //1 * 1 = 1	
        //2 * 1 = 2	2 * 2 = 4	
        //3 * 1 = 3	3 * 2 = 6	3 * 3 = 9	
        //4 * 1 = 4	4 * 2 = 8	4 * 3 = 12	4 * 4 = 16	
        //5 * 1 = 5	5 * 2 = 10	5 * 3 = 15	5 * 4 = 20	5 * 5 = 25	
        //6 * 1 = 6	6 * 2 = 12	6 * 3 = 18	6 * 4 = 24	6 * 5 = 30	6 * 6 = 36	
        //7 * 1 = 7	7 * 2 = 14	7 * 3 = 21	7 * 4 = 28	7 * 5 = 35	7 * 6 = 42	7 * 7 = 49	
        //8 * 1 = 8	8 * 2 = 16	8 * 3 = 24	8 * 4 = 32	8 * 5 = 40	8 * 6 = 48	8 * 7 = 56	8 * 8 = 64	
        //9 * 1 = 9	9 * 2 = 18	9 * 3 = 27	9 * 4 = 36	9 * 5 = 45	9 * 6 = 54	9 * 7 = 63	9 * 8 = 72	9 * 9 = 81	
        public static void b() {
            string[,] arr = new string[9, 9];
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    Console.Write((i+1)+"*"+(j+1)+"="+(i+1)*(j+1)+" ");
                }
                Console.WriteLine();
            }
            Console.ReadKey();
        }
        //用户输入正方形边长，用* 打印出空心正方形。
        //如：用户输入5，则输出如下图形。
        //*****
        //**
        //**
        //**
        //*****
        public static void c()
        {

            Console.WriteLine("请输入正方形的边长：");
            int ab = int.Parse(Console.ReadLine());
            int[,] arr = new int[ab, ab];
            for (int i = 0; i < ab; i++)
            {
                for (int j = 0; j <ab; j++)
                {
                    if (i >= 1 && i <= ab - 2 && j>=1 && j<=ab-2) {
                        Console.Write(" "+" ");
                    } else{
                        Console.Write("*"+" ");
                    }
                }
                Console.WriteLine();
            }
            Console.ReadKey();
        }     
          //  *
          // ***
          //*****
          // ***
          //  *
          //边长是3
          //行列数就是5
        public static void d()
        {
            Console.WriteLine("请输入菱形的边长（奇数）");
            int a = int.Parse(Console.ReadLine());

            string[,] arr = new string[a * 2, a * 2];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    if (i <= a && j > a - i && j < a + i || a < i && j > i - a && j <= 3 * a - 1 - i)
                    {
                        arr[i, j] = "*";
                    }
                    else
                    {
                        arr[i, j] = " ";
                    }
                }
            }
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    Console.Write(arr[i, j]);
                }
                Console.WriteLine();
            }
        }
        //如果一个数组保存元素是有序的（从大到小），
        //向这个数组中插入一个数，使得插入后的数组元素仍然保持有序。
        public static void e() {
            int[] arr = new int[6];
            arr[0] = 1;
            arr[1] = 10;
            arr[2] = 15;
            arr[3] = 44;
            arr[4] = 57;
            Console.WriteLine("请输入一个数：");
            int n = int.Parse(Console.ReadLine());
            arr[5] = n;
            int t;
            for (int i = 0; i <= 5; i++)
            {
                if (arr[i] < arr[i-1])
                {
                    t = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = t;
                }
            }
            for (int i = 0; i <=5; i++)
            {
                Console.WriteLine(arr[i]);
            }
            Console.ReadKey();
            

        }
        public static void f() {
            int[,] a= new int[10, 11];
            for (int i = 0; i < 10; i++)
            {
                a[i, 0] = 1;
                a[i, i] = 1;
            }
            for (int i = 0; i < 10; i++)
            {
                for (int j = 1; j < i; j++)
                {
                    a[i, j] = a[i - 1, j - 1] + a[i - 1, j];
                }
            }
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j <=i ; j++)
                {
                    Console.Write(a[i,j]+" ");
                }
                Console.WriteLine();
            }
            Console.ReadKey();
        }
    } 
}
